PATHMac OS 8 Developer Documentation > Operating System Services > Multiprocessing Services >

Adding Multitasking Capability to Applications Using Multiprocessing Services

   

MPEnterCriticalRegion

Attempts to enter a critical region.

OSStatus MPEnterCriticalRegion (
                     MPCriticalRegionID criticalRegion,
                     Duration timeout);
criticalRegion
A value of type MPCriticalRegionID that specifies the ID of the critical region you want to enter.
timeout
A value of type Duration that specifies the maximum time to wait for entry before timing out. See Timer Duration Constants for a list of constants you can use to specify the wait interval.
function result
A result code. See Result Codes for a list of possible values.
DISCUSSION

If another task currently occupies the critical region, the current task is blocked until the critical region is released or until the designated timeout expires. Otherwise the task enters the critical region and MPEnterCriticalRegion increments the region's use count.

Once a task enters a critical region it can make further calls to MPEnterCriticalRegion without blocking (its use count increments for each call). However, each call to MPEnterCriticalRegion must be balanced by a call to MPExitCriticalRegion ; otherwise the region is not released for use by other tasks.

Note that you can enter a critical region from a cooperative task. Each cooperative task is treated as unique and different from any preemptive task. If you call this function from a cooperative task, you should specify only kDurationImmediate for the timeout length; other waits will cause the task to block.

VERSION NOTES

Introduced with Multiprocessing Services 1.0.

SEE ALSO

The function MPExitCriticalRegion .


© 1999 Apple Computer, Inc. – (Last Updated 07 May 99)